package io.renren.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.sys.dao.ColumnsInfoDao;
import io.renren.modules.sys.entity.ColumnsInfoEntity;
import io.renren.modules.sys.entity.ColumnsInfoExcel;
import io.renren.modules.sys.service.ColumnsInfoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("columnsInfoService")
public class ColumnsInfoServiceImpl extends ServiceImpl<ColumnsInfoDao, ColumnsInfoEntity> implements ColumnsInfoService {

    @Autowired
    private ColumnsInfoDao columnsInfoDao;


    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        //String connid = (String) params.get("connid");
        String tableid = (String) params.get("tableid");


        IPage<ColumnsInfoEntity> page = this.page(
                new Query<ColumnsInfoEntity>().getPage(params),
                new QueryWrapper<ColumnsInfoEntity>()
                        .eq(StringUtils.isNotBlank(tableid), "table_id", tableid)

        );

        return new PageUtils(page);
    }

    @Override
    public List<ColumnsInfoExcel> getByTableid(String tableid) {
        List<ColumnsInfoExcel> list = columnsInfoDao.getByTableid(tableid);
        return list;
    }

}
